<?php
namespace plugin\ky_black\app\admin\model;

use support\Model;

class CardRecharge extends Model
{
    /**
     * 关联到模型的数据表
     *
     * @var string
     */
    protected $table = 'ky_card_recharge';

    /**
     * 主键
     *
     * @var string
     */
    protected $primaryKey = 'recharge_id';

    /**
     * 可以批量赋值的属性
     *
     * @var array
     */
    protected $fillable = [
        'recharge_no',
        'card_id',
        'card_no',
        'amount',
        'payment_type',
        'payment_account',
        'payment_bank',
        'payment_time',
        'verify_status',
        'verify_user_id',
        'verify_time',
        'effect_time',
        'status',
        'remark'
    ];

    /**
     * 类型转换
     *
     * @var array
     */
    protected $casts = [
        'amount' => 'decimal:2',
        'verify_status' => 'boolean',
        'payment_time' => 'datetime',
        'verify_time' => 'datetime',
        'effect_time' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];

    /**
     * 关联黑卡
     */
    public function blackCard()
    {
        return $this->belongsTo(BlackCard::class, 'card_id', 'card_id');
    }

    /**
     * 关联核实人
     */
    public function verifyUser()
    {
        return $this->belongsTo(Member::class, 'verify_user_id', 'user_id');
    }
} 